package com.yayan.util;

import java.security.MessageDigest;

import sun.misc.BASE64Encoder;

public class EncryptUtil {

	static public String EncoderByMd5(String str){
		String newstr = "";
		try{
			//确定计算方法,MD5加密是不可逆的
			MessageDigest md5=MessageDigest.getInstance("MD5");
			BASE64Encoder base64en = new BASE64Encoder();
			//加密后的字符串
        	newstr = base64en.encode(md5.digest(str.getBytes("utf-8")));        	
		}catch(Exception e){
			newstr = str;
		}
        return newstr;
	}
}
